home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group98a.txt / 000165_icon-group-sender _Wed Apr 15 13:04:21 1998.msg < prev    next >
Internet Message Format  |  2000-09-20  |  2KB

  1. Return-Path: <icon-group-sender>
  2. Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
  3.     by baskerville.CS.Arizona.EDU (8.8.8/8.8.7) with SMTP id NAA20416
  4.     for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Wed, 15 Apr 1998 13:04:20 -0700 (MST)
  5. Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
  6.     id AA27990; Wed, 15 Apr 1998 13:04:19 -0700
  7. Date: Wed, 15 Apr 1998 08:11:36 -0700
  8. From: swampler@noao.edu (Steve Wampler)
  9. Subject: Re: Tables of records
  10. To: icon-group@optima.CS.Arizona.EDU
  11. Message-Id: <swampler-9803151511.AA001617811@orpheus.gemini.edu>
  12. In-Reply-To: <78201599.35340ec3@aol.com>
  13. Errors-To: icon-group-errors@optima.CS.Arizona.EDU
  14. Status: RO
  15. Content-Length: 1560
  16.  
  17.  
  18.  
  19. DLucido wrote:
  20. > I am brand new to Icon (Just got the book this week) and I have been
  21. > experimenting
  22. > with some code to test my understanding.  While the following is not in any 
  23. > doucumentation I have found, it works.  I defined a record and created a table
  24. > of
  25. > records with  the following code:
  26. > record node(value,lchild,rchild)
  27. > procedure main(arg)
  28. >    tree:=table()
  29. >    tree[1]:=node(2,3,"Hello")
  30. >    tree[2]:=node(5,6,"World")
  31. >    tree[3]:=node(0,1,"Oops")
  32. >    every i:=key(tree)do
  33. >     write(i,":",tree[i].rchild)
  34. > end
  35. > While the order of the keys in unpredictable, the code can store a table of
  36. > records.
  37. > Is this a feature or something that should be avoided?
  38. >                                                          David Lucido
  39. >                                                           dlucido@aol.com
  40.  
  41. Any variable in Icon (elements of lists, tables, and sets, as well as record fields,
  42. are all variables) can hold any type in Icon.  This is very much by design.  The
  43. only object that only holds a specific type is a character set (cset), which can
  44. only hold characters [also by design].
  45.  
  46. By all means, don't avoid this.
  47.  
  48. The order is unpredictable because tables are really annotated sets, which,
  49. like sets in general, are unordered.  You can use the sort() function to obtain
  50. values (and keys) from a table or set in a predetermined order.
  51.  
  52. --
  53. Steve Wampler - swampler@gemini.edu [Gemini 8m Telescopes Project (under AURA)]
  54. The gods that smiled at your birth are now laughing openly. (Fortune Cookie)
  55.